import 'package:cms/api/term.dart';
import 'package:cms/models/term.dart';
import 'package:common/dio/model.dart';
import 'package:common/export/bloc.dart';
import 'detail_state.dart';

class CmsCategoriesDetailCubit extends Cubit<CmsCategoriesDetailState> {
  final int id;
  CmsCategoriesDetailCubit({required this.id})
    : super(CmsCategoriesDetailState().init()) {
    getTerm(id);
  }
  void getTerm(int id) async {
    try {
      LarapressResponse<WpTerm> response = await LaraPressTermApi().getTerm(id);
      emit(state.copyWith(term: response.data));
    } finally {
      emit(state.copyWith(isLoading: false));
    }
  }
}
